function initLogin() {
	var a = $("#theform")
			.validate(
					{
						onfocusin :false,
						onfocusout :false,
						highlight :false,
						unhighlight :false,
						submitHandler : function(b) {
							var c = $(b).serializeArray();
							$(b).disabled();
							$("#loginmsg")
									.warning(
											"\u767b\u9646\u4e2d\uff0c\u8bf7\u7a0d\u5019\u2026");
							$.ajax(  {
								type :"POST",
								url :$(b).attr("action"),
								data :c,
								dataType :"json",
								success : function(e) {
									$("#loginmsg").warning(e.msg);
									if (e.success) {
										var d = e.url ? e.url : "/";
										setTimeout( function() {											
											window.location = d
										}, 800)
									} else {
										$(b).enabled()
									}
								},
								error : function(d) {
									$(b).enabled()
								}
							});
							return false
						},
						rules : {
							account : {
								required :true
							},
							password : {
								required :true
							}
						},
						messages : {
							account : {
								required :"\u8bf7\u8f93\u5165\u7528\u6237\u540d\u79f0"
							},
							password : {
								required :"\u8bf7\u8f93\u5165\u5bc6\u7801"
							}
						}
					});
	return a
}
//始页
function initRegForm() {
	
	$("#input_question").change(function(){
     $("#question").val(""+$("#input_question").val());
});
	
	$(":radio[name=passport]").click(
			function() {
				$("#ent,#personal").hide();
				$("#" + this.value + " input[type=text]").removeClass("error")
						.removeClass("success");
				$("#" + this.value + " label.error").warning();
				$("#" + this.value).show()
			});
	$("#seccode").focus( function() {
		if ($("#getcode:hidden").size()) {
			$("#code-img").attr("src", "../Include/VerifyCode.asp?" + Math.random());
			$("#seccode").attr("value", "")
			$("#getcode").show()
		}
	});
	$("#getcode a").click( function() {
		$("#code-img").attr("src", "../Include/VerifyCode.asp?" + Math.random());
		$("#seccode").attr("value", "")
		$("#seccode").focus();
		return false
	});
	validateRegForm();
	$(":radio[name=passport]:eq(0)").click();
	$(":radio[name=type]:eq(1)").click();
	$("#account").blur(
			function() {
				var a = this;
				if (!$(a).hasClass("success")) {
					return
				}
				$.ajax( {
					type :"POST",
					url :"register_check_username.asp",//欠突
					data : {
						act :"check",
						type :a.id,
						value :a.value
					},
					dataType :"json",
					success : function(b) {
						if (!b.success) {
							$(a).removeClass("success").addClass("error");
							$("label[for='" + a.id + "']").html(b.msg)
									.removeClass("success");
							$("#" + a.id + "_valid").val("0")
						} else {
							$("label[for='" + a.id + "']").html(b.msg);
							$("#" + a.id + "_valid").val("1")
						}
					}
				})
			})
}
function register(a) {
	var c = $(":radio[name=passport]:not(:checked)").val();
	$("#" + c + " :input").attr("disabled", true);
	var a = $(a);
	var d = $("#result");
	var b = a.serializeArray();
	if ($("#account_valid").val() == "0") {
		alert("\u5bf9\u4e0d\u8d77\uff0c\u8be5\u7528\u6237\u540d\u5df2\u7ecf\u88ab\u6ce8\u518c\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
		$("#account").focus();
		return
	}
	if ($("#nick_valid").val() == "0") {
		alert("\u5bf9\u4e0d\u8d77\uff0c\u8be5\u6635\u79f0\u5df2\u7ecf\u88ab\u4f7f\u7528\uff0c\u8bf7\u91cd\u65b0\u8f93\u5165");
		$("#nick").focus();
		return
	}
	a.disabled();
	d.warning(TXT_POSTDATA);
	//峤蛔?
	$.ajax( {
		type :"POST",
		url :a.attr("action"),
		data :b,
		dataType :"json",
		success : function(e) {
			d.warning(e.msg);
			//alert('1111window.location ='+e.success);
			if (e.success) {
				setTimeout( function() {
					window.location = "welcome.asp"
				}, 500)
			} else {
				a.enabled()
			}
		},
		error : function(e) {
			d.warning(TXT_NETBUSY);
			a.enabled()
		}
	})
}
//页校
function validateRegForm() {
	var a = $("#regform")
			.validate(
					{
						errorPlacement : function(b, c) {
							b.appendTo(c.parent("td"))
						},
						showErrors : function() {
							var f = [];
							for ( var e = 0; this.errorList[e]; e++) {
								var c = this.errorList[e];
								var d = c.element;
								$(d).removeClass("success").addClass("error");
								if (d.alt) {
									f[d.alt] = true;
									d = $("#" + c.element.alt)[0]
								}
								this.showLabel(d, c.message)
							}
							for ( var e = 0; this.successList[e]; e++) {
								var b = true;
								var d = this.successList[e];
								if (d.alt) {
									$(d).addClass("success").removeClass(
											"error");
									if (f[d.alt]) {
										b = false
									} else {
										d = $("#" + d.alt)[0]
									}
								}
								if (b) {
									this.showLabel(d)
								}
							}
						},
						success : function(b) {
							b.text("\u586b\u5199\u6b63\u786e").addClass(
									"success");
							$("#" + b.attr("for")).addClass("success")
						},
						submitHandler : function(b) {
							register(b)
						},
						rules : {
							account : {
								required :true,
								rangelength : [ 5, 16 ],
								account :true
							},
							nick : {
								required :true,
								minLengthW :4
							},
							pwd1 : {
								required :true,
								rangelength : [ 5, 16 ],
								password :true
							},
							pwd2 : {
								required :true,
								equalTo :"#pwd1"
							},
							question : {
								required :true,
								rangelength : [ 3, 16 ]
							},
							answer : {
								required :true,
								rangelength : [ 3, 16 ]
							},
							email : {
								required :true,
								email :true
							},
							address : {
								required :true,
								minlength :8
							},
							postcode : {
								required :true,
								digits :true,
								rangelength : [ 6, 6 ]
							},
							country :"required",
							province :"required",
							city :"required",
							seccode : {
								required :true,
								rangelength : [ 4, 4 ]
							},
							contactor : {
								required :"#t1:checked",
								cnname :true,
								rangelength : [ 2, 5 ]
							},
							gender : {
								required :"#t1:checked"
							},
							idtype : {
								required :"#t1:checked"
							},
							idnumber : {
								required :"#t1:checked",
								minlength :8
							},
							//telarea : {
							//	required :"#t1:checked",
							//	digits :true
							//},
							telnum : {
								required :"#t1:checked",
								digits :true,
								minlength :6
							},
							//telext : {
							//	required : function() {
							//		return ($("#t1:checked").size() > 0 && !!$(
							//				"#telext").val())
							//	},
							//	digits :true
							//},
							mobile : {
								required :"#t1:checked",
								mobile :true
							},
							enterprise : {
								required :"#t2:checked",
								minlength :4
							},
							industry : {
								required :"#t2:checked"
							},
							admin_name : {
								required :"#t2:checked",
								cnname :true
							},
							admin_gender : {
								required :"#t2:checked"
							},
							//admin_telarea : {
							//	required :"#t2:checked",
							//	digits :true
							//},
							//admin_telnum : {
							//	required :"#t2:checked",
							//	digits :true,
							//	minlength :20
							//},
							//admin_telext : {
							//	required : function() {
							//		return ($("#t2:checked").size() > 0 && !!$(
							//				"#admin_telext").val())
							//	},
							//	digits :true
							//},
							admin_mobile : {
								required :"#t2:checked",
								mobile :true
							}
						},
						messages : {
							account : {
								required :"\u8bf7\u8f93\u5165\u7528\u6237\u540d",
								rangelength :$
										.format("\u7528\u6237\u540d\u957f\u5ea6{0}-{1}\u4f4d\u4e4b\u95f4"),
								account :"\u7528\u6237\u540d\u7531\u6570\u5b57\u3001\u82f1\u6587\u3001\u4e2d\u6760\u7ebf\u7ec4\u6210\uff0c\u4e0d\u80fd\u4e3a\u7eaf\u6570\u5b57\u6216\u8fde\u7eed\u4e2d\u6760\u7ebf"
							},
							nick : {
								required :"\u8bf7\u8f93\u5165\u6635\u79f0",
								minLengthW :"\u6635\u79f0\u9650\u5236\u6700\u5c11\u4e3a4\u4e2a\u82f1\u6587\u5b57\u7b26\u6216\u4e24\u4e2a\u4e2d\u6587\u5b57\u7b26"
							},
							pwd1 : {
								required :"\u8bf7\u8f93\u5165\u767b\u9646\u5bc6\u7801",
								rangelength :$
										.format("\u5bc6\u7801\u957f\u5ea6{0}-{1}\u4f4d\u4e4b\u95f4"),
								password :"\u5bc6\u7801\u8fc7\u4e8e\u7b80\u5355\uff0c\u4e0d\u80fd\u7eaf\u6570\u5b57"
							},
							pwd2 : {
								required :"\u8bf7\u786e\u8ba4\u767b\u9646\u5bc6\u7801",
								equalTo :"\u4e24\u6b21\u5bc6\u7801\u8f93\u5165\u4e0d\u4e00\u81f4"
							},
							question : {
								required :"\u8bf7\u8f93\u5165\u5bc6\u7801\u4fdd\u62a4\u95ee\u9898",
								rangelength :$
										.format("\u5bc6\u7801\u4fdd\u62a4\u95ee\u9898\u957f\u5ea6{0}-{1}\u4f4d\u4e4b\u95f4")
							},
							answer : {
								required :"\u8bf7\u8f93\u5165\u5bc6\u7801\u4fdd\u62a4\u7b54\u6848",
								rangelength :$
										.format("\u5bc6\u7801\u4fdd\u62a4\u7b54\u6848\u957f\u5ea6{0}-{1}\u4f4d\u4e4b\u95f4")
							},
							email :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u7535\u5b50\u90ae\u7bb1",
							postcode :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u90ae\u653f\u7f16\u7801",
							address :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u8054\u7cfb\u5730\u5740",
							country :"\u8bf7\u9009\u62e9\u56fd\u5bb6",
							province :"\u8bf7\u9009\u62e9\u7701\u4efd",
							city :"\u8bf7\u9009\u62e9\u57ce\u5e02",
							seccode :"\u9a8c\u8bc1\u7801\u9519\u8bef",
							contactor :"\u8bf7\u8f93\u5165\u60a8\u7684\u771f\u5b9e\u59d3\u540d",
							gender :"\u8bf7\u9009\u62e9\u60a8\u7684\u6027\u522b",
							idtype :"\u8bf7\u9009\u62e9\u8bc1\u4ef6\u7c7b\u578b",
							idnumber :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u8bc1\u4ef6\u53f7\u7801",
							telarea :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u7535\u8bdd\u533a\u53f7",
							telnum :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u7535\u8bdd\u53f7\u7801",
							telext :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u5206\u673a\u53f7\u7801",
							mobile :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u624b\u673a\u53f7\u7801<a title='\u9999\u6e2f\u8bf7\u52a0(852)\u53f0\u6e7e\u8bf7\u52a0(886)\u6fb3\u95e8\u8bf7\u52a0(853)'>[?]</a>",
							enterprise :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u516c\u53f8\u540d\u79f0",
							industry :"\u8bf7\u9009\u62e9\u516c\u53f8\u6240\u5c5e\u884c\u4e1a",
							admin_name :"\u8bf7\u8f93\u5165\u8054\u7cfb\u4eba\u771f\u5b9e\u59d3\u540d",
							admin_gender :"\u8bf7\u9009\u62e9\u8054\u7cfb\u4eba\u6027\u522b",
							admin_telarea :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u7535\u8bdd\u533a\u53f7",
							//admin_telnum :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u7535\u8bdd\u53f7\u7801",
							admin_telext :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u5206\u673a\u53f7\u7801",
							admin_mobile :"\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u624b\u673a\u53f7\u7801<a title='\u9999\u6e2f\u8bf7\u52a0(852)\u53f0\u6e7e\u8bf7\u52a0(886)\u6fb3\u95e8\u8bf7\u52a0(853)'>[?]</a>"
						}
					});
	return a
}
function getSMSCode(f) {
	var b = $F("verify_mobile");
	if (!ORAY.checkMobile(b)) {
		return ORAY
				.inputWrong("verify_mobile", "verify_mobile_msg",
						"\u8bf7\u6b63\u786e\u8f93\u5165\u60a8\u7684\u624b\u673a\u53f7\u7801\uff01")
	}
	f.disabled = true;
	var a = "/ASP_PAGES/Passport/Passport_Register.asp";
	var e = "send=sms&mobile=" + b;
	var c = {
		method :"post",
		parameters :e,
		onSuccess : function(g) {
			ORAY.inputWrong("verify_mobile", "verify_mobile_msg",
					g.responseText)
		},
		onFailure : function() {
			ORAY
					.inputWrong("verify_mobile", "verify_mobile_msg",
							"\u7f51\u7edc\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5...")
		}
	};
	var d = new Ajax.Request(a, c)
}
function initForget() {
	var a = $("#forgetform").submit( function() {
		return false
	});
	var b = $("#result");
	$("#seccode").focus( function() {
		if ($("#getcode:hidden").size()) {
			$("#code-img").attr("src", "../Include/VerifyCode.asp?" + Math.random());
			$("#getcode").show()
		}
	});
	$("#getcode a").click( function() {
		$("#code-img").attr("src", "../Include/VerifyCode.asp?" + Math.random());
		$("#seccode").focus();
		return false
	});
	a.submit( function() {
		if (a.find("input[name=act]").size()) {
			var d = a.serializeArray();
			a.disabled();
			b.warning(TXT_POSTDATA);
			$.ajax( {
				type :"POST",
				url :a.attr("action"),
				data :d,
				dataType :"json",
				success : function(e) {
					b.warning(e.msg);
					if (!e.success) {
						$("#code-img").attr("src",
								"../Include/VerifyCode.asp?" + Math.random());
						a.enabled()
					}
				},
				error : function(e) {
					b.warning(TXT_NETBUSY);
					a.enabled()
				}
			})
		} else {
			var c = $.trim($("#account").val());
			if (!c) {
				b.warning("\u8bf7\u8f93\u5165\u60a8\u7684\u7528\u6237\u540d");
				$("#account").focus();
				return
			}
			this.submit()
		}
	})
};
